<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/common.php';


$item_id = $_GET['item_id'];
$item = item::getById($item_id);
$user_id = user::getId();

if (empty($user_id) || empty($item))
{
	echo json_encode(array('result'=>false,'code'=>1));
	return false;
}

$x = $_POST['x'];
$y = $_POST['y'];
$comment = $_POST['comment'];

$circle_id = item::circle($item_id, $x, $y, $comment);
if ($circle_id) {
	echo json_encode(array('result'=>true,'circle_id'=> $circle_id));
} else {
	echo json_encode(array('result'=>false,'code'=>2));
}
